-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support many nested forms #5
base: master
Are you sure you want to change the base?
Add support many nested forms #5
Conversation
I second this pull request. 😅 I'm currently using it on a few sites and it's working great. |
Thanks @NikitaNaumenko for the PR Can you fix conflicts so I can review it? |
@guillaumebriday yep, I'll do it |
90532c4
to
11f2406
Compare
@guillaumebriday done! |
Hi. Hi @guillaumebriday do you have an idea of when this may get merged? Thanks |
Hey folks. Maybe I have this wrong, but it looks like you can use multiple nested forms now. I should probably have commented on this ticket, but I've left notes here: #8 (comment) Basically, just moving the controller attributes out of the |
I think the problem is this line |
Allowing to customize the NEW_RECORD placeholder for each nested form builder worked for me.
In my case the first form receives a child_index placeholder of "NEW_RECORD_1" and the deep nested receives "NEW_RECORD_2" for example. |
Using a custom stimulus value solves this issue but maybe a smarter way to set this id could bring a better experience. Any ideas? |
Can confirm @aquilarafa 's idea works for many layers of nested forms. @ferrisoxide I think the issue is when you need to have a nested form that has 2 layers or more, the
Notice the same id for both parent and child records. This will make the form only submit the last item created in the 2nd layer, because all inputs in that layer will have the same name. The correct template name value should be something like this:
For a slightly "smarter" solution, I guess since we can get child_index value from the form builder:
We can add a hidden field to the template, then figure out the given child index from the Stimulus controller? |
In one of my pet project, I've found the issue. That component doesn't work if you need to have more than one nested model form. I've fixed and also save the compatibility with one model nested form.